<template>
  <view>
    <view class="mt-2 mb-2 c-text-14">最新检测</view>
    <van-cell-group inset>
      <van-cell title="体温" use-label-slot>
        <view slot="right-icon">
          {{ examineInfo?.temp + '℃' || '-' }}
        </view>
      </van-cell>
      <van-cell title="心率" use-label-slot>
        <view slot="right-icon">
          {{ examineInfo?.heart + 'bpm' || '-' }}
        </view>
      </van-cell>

      <van-cell title="血氧" use-label-slot>
        <view slot="right-icon">
          {{ examineInfo?.oxygen + 'spo2' || '-' }}
        </view>
      </van-cell>
      <van-cell title="血压" use-label-slot>
        <view slot="right-icon">
          <van-tag plain type="primary" size="large">{{ examineInfo?.pressureMin + 'mmHg' || '-' }}</van-tag> -
          <van-tag plain type="success" size="large">{{ examineInfo?.pressureMax + 'mmHg' || '-' }}</van-tag>
        </view>
      </van-cell>
    </van-cell-group>
  </view>
</template>

<script setup lang="ts">
import EquipRequest from '@/request/equipRequest';

const props = defineProps<{ equipId: number }>();
const examineInfo = ref<IGetExamineInfo | undefined>(undefined);

onMounted(() => {
  getExamineInfo();
});

const updateExamineData = () => {
  getExamineInfo();
};

//任意组件触发头部组件的更新
provide('updateExamineData', updateExamineData);

const getExamineInfo = () => {
  EquipRequest.GetExamineInfo({ equipId: props.equipId }).then((res) => {
    examineInfo.value = res.data;
  });
};
</script>
